package com.itheima.exerciseTest.method30_39.method34;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(19999);
        ThreadPoolExecutor pool = new ThreadPoolExecutor(5,
                10,
                1, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(5),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        while(true){
            Socket accept = ss.accept();
            ThreadServer ts = new ThreadServer(accept);
            pool.submit(ts);



        }
    }
}
